Your Project Title Here

Header 1 (Section heading)

Header 2 (Subsection heading)

Header 3 (Subsubsection heading)

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For example, you can include Bold and Italic and Code text. For more details on using R Markdown see http://rmarkdown.rstudio.com.

You should test out updating your GitHub Pages website:

  • clone your group’s blog project repo in RStudio
  • update “Your Project Title Here” to a new title in the YAML header
  • knit index.Rmd (we will now knit to HTML by default instead of pdf)
  • commit and push both index.Rmd and index.html
  • go to https://stat231-f21.github.io/blog_your-group-name/ to see the published test document (this is publicly available!)

Including code and plots

You can embed code as normal, for example:

##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Let’s clean up the format of that output instead of using the standard R output:

summary(cars) %>%
  kable(col.names = c("Speed", "Distance"),
        row.names = FALSE) %>%
  kable_styling(bootstrap_options = "striped",
                full_width = FALSE) %>%
  row_spec(0, bold = TRUE) %>%
  column_spec(1:2, width = "1.5in") 
Speed Distance
Min. : 4.0 Min. : 2.00
1st Qu.:12.0 1st Qu.: 26.00
Median :15.0 Median : 36.00
Mean :15.4 Mean : 42.98
3rd Qu.:19.0 3rd Qu.: 56.00
Max. :25.0 Max. :120.00

In a study from the 1920s, fifty cars were used to see how the speed of the car and the distance taken to stop were related. Speeds ranged between 4 and 25 mph. Distances taken to stop ranged between 2 and 120 feet, with the middle 50% falling between 26 and 56 feet.

You can also embed plots as normal, for example:

Take note of the default code chunk options in the setup code chunk, and adjust individual code chunk options as needed. for example, unlike the rest of the Rmd files we worked in this semester, the default code chunk option is echo = FALSE, so you will need to set echo = TRUE for any code chunks you would like to display in the blog.

Including equations

Equations may be needed if you are explaining a new technique or perhaps providing some other relevant formulas in your exposition. There are two ways to include equations:

  • Inline: \(b \sim N(0, \sigma^2_b)\)
  • Display-style (displayed on its own line): \[\frac{\sigma^2_b}{\sigma^2_b + \sigma^2_e}\]

For typesetting equations appropriately, take a look at the Symbols in math mode section of this cheat sheet (or do some extra Googling—there are many resources).

Embedding Shiny apps

To embed Shiny apps, you must publish your Shiny app to shinyapps.io (or the Amherst Shiny server). Make sure the YAML header includes the line self_contained: false. Then you can use this code chunk below, adjusting the width and height as needed to accommodate your Shiny app.

To deploy an app to the Amherst Shiny server, do the following:

  1. Go to r.amherst.edu and log in.
  2. Go to your Home directory on the server and create a new folder called ShinyApps if it doesn’t already exist (make sure you match the case).
  3. Set up your blog repo on the server using the directions from the first week of the semester (creating tokens to authenticate, then creating a new Version Control project, etc.).
  4. Once you’ve set up and pulled your blog repo on the server, copy the completed Shiny app folder to the ShinyApps folder in your Home directory.
  5. Your app has now been deployed! Run it by going to r.amherst.edu/apps/your-user-name/your-app-folder-name.

You can even create tabs within your webpage if you want!

Every subsection heading (starting with ##) until you create a new section heading (starting with #) will be a new tab.

Bulleted list

You can make a bulleted list like this:

  • item 1
  • item 2
  • item 3

Numbered list

You can make a numbered list like this

  1. First thing I want to say
  2. Second thing I want to say
  3. Third thing I want to say

Customizing your blog design

As a final detail only if you have time, you can explore options for customizing the style of your blog. By default, we are using the readthedown theme from the rmdformats package (see Line 6 of this file if you want to switch out themes). There are, I’m sure, many many many more similar packages with built in themes, or you can look into how to include a CSS code chunk to customize aspects of the current theme.

There are some easy-to-change options that you can play around with:

  • The theme itself (Line 6): rmdformats::readthedown, rmdformats::downcute, rmdformats::robobook, rmdformats::material,
    • For downcute only, you can add a new indented line below Line 6 with the code downcute_theme: "chaos" for the downcute chaos theme
    • I would not recommend the other themes that do not have the sidebar navigation
  • Syntax highlighting options (Line 8, highlight): "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", "haddock", or "textmate" (or NULL for no syntax highlighting)

You can explore additional customizable YAML options by looking at the rmdformats package page or running, for example, ?rmdformats::readthedown() to see the help documentation for a particular theme from the package.